package com.erms.lab.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.erms.common.annotation.Log;
import com.erms.common.enums.BusinessType;
import com.erms.lab.domain.SysFurther;
import com.erms.lab.service.ISysFurtherService;
import com.erms.common.core.controller.BaseController;
import com.erms.common.core.domain.AjaxResult;
import com.erms.common.utils.poi.ExcelUtil;
import com.erms.common.core.page.TableDataInfo;

/**
 * 接受进修人员情况Controller
 * 
 * @author guo
 * @date 2020-03-22
 */
@Controller
@RequestMapping("/lab/further")
public class SysFurtherController extends BaseController
{
    private String prefix = "lab/further";

    @Autowired
    private ISysFurtherService sysFurtherService;

    @RequiresPermissions("lab:further:view")
    @GetMapping()
    public String further()
    {
        return prefix + "/further";
    }

    /**
     * 查询接受进修人员情况列表
     */
    @RequiresPermissions("lab:further:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysFurther sysFurther)
    {
        startPage();
        List<SysFurther> list = sysFurtherService.selectSysFurtherList(sysFurther);
        return getDataTable(list);
    }

    /**
     * 导出接受进修人员情况列表
     */
    @RequiresPermissions("lab:further:export")
    @Log(title = "接受进修人员情况", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysFurther sysFurther)
    {
        List<SysFurther> list = sysFurtherService.selectSysFurtherList(sysFurther);
        ExcelUtil<SysFurther> util = new ExcelUtil<SysFurther>(SysFurther.class);
        return util.exportExcel(list, "further");
    }

    /**
     * 新增接受进修人员情况
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存接受进修人员情况
     */
    @RequiresPermissions("lab:further:add")
    @Log(title = "接受进修人员情况", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysFurther sysFurther)
    {
        return toAjax(sysFurtherService.insertSysFurther(sysFurther));
    }

    /**
     * 修改接受进修人员情况
     */
    @GetMapping("/edit/{furId}")
    public String edit(@PathVariable("furId") Long furId, ModelMap mmap)
    {
        SysFurther sysFurther = sysFurtherService.selectSysFurtherById(furId);
        mmap.put("sysFurther", sysFurther);
        return prefix + "/edit";
    }

    /**
     * 修改保存接受进修人员情况
     */
    @RequiresPermissions("lab:further:edit")
    @Log(title = "接受进修人员情况", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysFurther sysFurther)
    {
        return toAjax(sysFurtherService.updateSysFurther(sysFurther));
    }

    /**
     * 删除接受进修人员情况
     */
    @RequiresPermissions("lab:further:remove")
    @Log(title = "接受进修人员情况", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysFurtherService.deleteSysFurtherByIds(ids));
    }
}
